package com.job.DQH.dqh715.inClass;

public class StringEX02 {
    public static void main(String[] args) {
        //练习：将数字与字母混合的字符串中的数字拿出来并求和，且连续的数字要当成一个整数
        String s = "sd9ad1sdawd1s5d1a664w8a8sd6ad5awd1ada8d4a6d40a";
        String num = "0";//此处必须为带内容的字符串，初始化字符串不能用空字符串
        int count = 0;

        for (int i = 0; i <s.length(); i++) {
            if(Character.isDigit(s.charAt(i))){
                num = num + s.charAt(i);
            }else{
                count = count + Integer.parseInt(num);
                num = "0";
            }
        }
        count += Integer.parseInt(num);
        System.out.println(count);
    }
}
